<template>
    <div class="login">
        <div class="login_box">
            <div class="login_circular">
                <img src="../assets/logo.png" alt="">
            </div>
            <div class='login_form'>
                <el-form ref="form" :model="form" label-width='80px'>
                    <el-form-item label="用户名" prop="username" :rules="[{required: true, message: '请填入用户名', trigger: 'blur'}]">
                        <el-input v-model="form.username" placeholder="请输入用户名"
                         ></el-input>
                    </el-form-item>
                    <el-form-item label="密码" prop="password" :rules="[{required: true, message: '请填入密码', trigger: 'blur'}]">
                        <el-input v-model="form.password" placeholder="请输入密码"></el-input>
                    </el-form-item>
                    <el-form-item style="text-align:right;">
                        <el-button type="primary" @click="onSubmit">登录</el-button>
                        <el-button @click="reset">重置</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
// import {logins} from '../until/http.js'
export default {
  name: "HouLogin",
  data() {
    return {
      form: {
        username: "",
        password: ""
      }
    };
  },
  mounted() {},
  methods: {
    //登录
    onSubmit() {
      this.$refs.form.validate(async valid => {
        if (!valid) {
          return;
        } else {
          this.$store
            .dispatch("users/denglu", this.form)
            .then(res => {
              this.$message.success(res);
                this.$router.push("/home")
            })
            .catch(res => {
              this.$message.error(res);
            });
        }
      });
    },
    //   重置
    reset() {
      this.form = {};
    }
  }
};
</script>
<style  scoped>
.login {
  width: 100vw;
  height: 100vh;
  background-color: #2b4b6b;
}
.login_box {
  width: 500px;
  height: 300px;
  background: rgba(230, 229, 229, 0.8);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 20px;
  box-sizing: border-box;
  border-radius: 5%;
}
.el-form{
    width: 100%;
}
.login_form {
  width: 90%;
  position: absolute;
  bottom: 20px;
}
.login_circular {
  width: 150px;
  height: 150px;
  box-sizing: border-box;
  border-radius: 50%;
  position: absolute;
  top: 0%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffff;
}
.login_circular img {
  width: 150px;
  height: 150px;
  border-radius: 50%;
}
</style>